package com.zzzzzz.app.account.dao;

import org.springframework.stereotype.Repository;

import com.zzzzzz.app.account.model.po.UserActivate;
import com.zzzzzz.core.dao.BaseDao;

@Repository
public class UserActivateDao extends BaseDao{
	
	private final static String FIND_ACTIVATE_BY_USERID = "select activate from user_activate where user_id = ?";
	private final static String FIND_USERID_BY_ACTIVATE = "select user_id from user_activate where activate = ?";
	private final static String ADD = "insert into user_activate(user_id, activate) values(:userId, :activate)";
	
	public String findActivateByUserId(Long userId){
		return findString(FIND_ACTIVATE_BY_USERID, String.class, userId);
	}
	
	public long findUserIdByActivate(String activate){
		return findLong(FIND_USERID_BY_ACTIVATE, activate);
	}
	
	public void add(UserActivate userActivate){
		update(ADD, userActivate);
	}
}
